import java.io.*;
import java.net.Socket;


public class ClientHandler implements Runnable {

	private InputStream inputStream;
	private Socket socket;
	private DataFileStorer fileStorer;
	//private DataStorer dataSaver;

	public ClientHandler(Socket sock, long toc, DataFileStorer fileStorer) throws IOException {
		socket = sock;
		inputStream = socket.getInputStream();
		this.fileStorer = fileStorer;	
	}

	@Override
	public void run() {		

		MyByteParser byteParser = new MyByteParser(fileStorer);		
		
		while(true) {
			try {
				int read = inputStream.read();

				if(read != -1){
					byteParser.process(inputStream);
				}
			} catch (IOException e) {			
				e.printStackTrace();
			}
		}
	}
}
